//期望这个类能够有唯一一个实例
class Singleton {
    private static Singleton instance = new Singleton();

    private Singleton() {
    }

    //通过这个方法获取到实例, 后续如果想用这个类的实例都通过getInstance
    public static Singleton getInstance() {
        return instance;
    }
}

public class Demo21 {
    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();

        System.out.println(s1 == s2);
    }
}
